1. Field of the Invention
The present invention relates to a programmable controller and a programmable controller operating method which facilitates initialization or intentional changing of internal data.
2. Description of the Related Art
FIG. 21 is a block diagram of a conventional programmable controller. A programmable controller unit 1 comprises a CPU 3 for performing arithmetic operations and processing to exercise internal control of the programmable controller unit 1. An input/output device 2, such as peripheral equipment or the like, performs several functions such as writing a sequence program and monitoring the internal status of the CPU module 3, along with performing other operations.
Programmable controller unit 1 further comprises a peripheral equipment interface 4, for coupling the programmable controller unit 1 to the input/output device via communication cable 4a. Peripheral equipment interface 4 operates to match the internal signal of the programmable controller unit 1 with a signal transmitted on the communication cable. Programmable controller unit 1 further comprises input/output port 5, system program memory 6 having a system program stored therein for operating the CPU 3, and sequence program memory 7 having sequence programs stored therein. The programmable controller unit 1 repeatedly executes the sequence programs; stored in the sequence memory 7.
Programmable controller unit 1 further comprises a first storage device 12, for example, a device memory for storing internal data. The device memory 12 comprises input device memory 8, for storing the states of input signals entered via the input/output port 5, output device memory 9, for storing the states of output signals output via the input/output port 5, internal device memory 10, for storing data indicating the results of arithmetic operations performed under the control of the sequence program, and peripheral equipment device memory 11, which is needed to perform a simulation operation which will be described later.
Operation of the programmable controller unit 1 will now be described.
The sequence program stored in the sequence program memory 7 is designed to change its operation according to the contents, etc., of the input device memory 8 and the internal device memory 10. Hence, prior to the start of sequence program execution, the contents of the device memory 12 must be initialized. The programmable controller 1 repeats the execution of a sequence program to perform operations as shown in FIG. 22.
When an operation start condition occurs at a power-on condition or the like, processing progresses from start step S601 to step S602, where the state of the input signal is obtained from the input/output port 5 and stored in the input device memory 8, and then advances to step S603.
In step S603, a sequence program for initializing the device memory 12 is run and processing moves to step S604. This initialization sequence is designed to initialize the device memory 12 only when the sequence program is being run the first time after start of operation.
FIG. 23 shows an example of a sequence program, such as a ladder program or the like, for performing initialization. Initialization sequence program 2301 is designed to transfer the contents of memory K100-K106 to addresses D0-D6 of internal device memory 10 when the data of an internal device M9038, or data at the predetermined address of the internal device memory 10, is set to "1" (ON). After initialization, the processing proceeds to step S604 as shown in FIG. 22.
In step S604, predetermined arithmetic operations are executed under the control of the sequence program with reference to the contents of the input device memory 8, the internal device memory 10, etc., and the arithmetic operation results are stored in the internal device memory 10 or the output device memory 9, and the processing advances to step S605. In step S605, the content of the output device memory 9 is output from the input/output port 5 and execution proceeds to step S606.
In step S606, if a processing request is provided by peripheral equipment 2, processing in response to that request is performed and processing moves to step S607. In step S607, it is determined whether an end request is provided by, for example, the peripheral equipment. If an end request is provided, the processing proceeds to end step S608, and the processing is terminated. However, if no end request is provided, the processing returns to step S601 and is repeated.
In accordance with the processing described above, it should be noted that the content of the input device memory 8 is changed according to the state of the input signal from the input/output device 2, and the contents of the output device memory 9 and the internal device memory 10 are changed according to the arithmetic operation results obtained in accordance with the sequence program. Also, the sequence program for initializing the device memory 12 as described above is designed to always run in a single cycle of the sequence program regardless of whether or not it actually performs initialization. This creates a problem, because as the number of steps in, the initialization sequence program increases, the time needed to execute a cycle of the sequence program increases.
In the conventional art, an operation method exists which is known as a simulation operation, wherein the contents of the input device memory 8, the output device memory 9 or the internal device memory 10 are intentionally changed. This operation method is used for program debugging or the like.
According to this simulation operation, during operation of the programmable controller unit 1, when the input/output device 2 provides a change request indicating that a portion of the device memory 12 is to be changed, and the peripheral equipment 2 provides instructions indicating the way in which that portion is to be changed, the programmable controller unit 1 can operate with the memory contents being changed as requested.
For example, when a external lamp is to be lit temporarily, an operator controls the input/output device 2 (peripheral equipment) to provide the programmable controller unit 1 with a request to set "on" (e.g., to "1") the predetermined address of the device memory 12 to which the lamp is assigned, and this request is executed by the programmable controller 1 in step S606 shown in FIG. 22. The predetermined address of the device memory 12 to which the lamp is assigned exists in the output device memory 9 of the device memory 12. When the predetermined address of the device memory 12 to which the lamp is assigned is set to "on" (e.g., "1"), the programmable controller 1 lights the lamp.
As described above, the contents of the output device memory 9 and the internal device memory 10 can be changed as requested by the input/output device 2 as indicated in, for example, step S606. However, as further described above, the contents of the input device memory 8 is based on the state of the input signal obtained from the input/output port 5. Therefore, even if the content of the input device memory 8 is intentionally changed in step S606, when the processing is repeated, the content of the input memory device 8 is again changed in step S602 in accordance with the states of the input signals being provided at that time (e.g., input signals from the input/output device 2). Hence, this new data now in the input device memory 8, not the data entered in step S606 to perform the simulation operation, is used by the CPU 3 when performing the arithmetic operation in step S604.
Therefore, in order to change the contents of the input device memory 8 in, for example, step S606, and have that data used in the arithmetic operation of step S604 during a simulation operation, the contents of the peripheral equipment device memory 11 are changed without the contents of the input device memory 8 being changed. Namely, the contents of the peripheral equipment device memory 11 are zeroed as initial values (i.e., all switched off) and switched on/off upon request. Then, in the simulation operation, the CPU 3 does not read the data of the input device memory 8 alone, but rather reads the arithmetic OR of the input device memory 8 data and the peripheral equipment device memory 11 data as the data of the internal device memory 8 at the time the arithmetic operation in step S604 is performed.
That is, if the switch of the actual external equipment is off, the data of the input device memory 8 corresponding to that switch is "0". However, if the data of the peripheral equipment device memory 11 is "1", the OR value of the data in the input device memory 8 and the peripheral equipment device memory 11 is "1". This data value of "1" is read by the CPU 3 as the simulation data of the input device memory 8 during the simulation operation. Hence, even where the switch is off during step S602, thus causing the data of the input device memory 8 corresponding to that switch to be "0", the desired simulated value "1" entered in peripheral equipment device memory 11 during step S606 is used in the arithmetic operation.
As evident from the above, several disadvantages exist in the conventional programmable controller. For example, a sequence program for initialization needs to be run at the start of operation to initialize the device memory 12, and much time is required to write such sequence program. Also, to change the contents of the device memory 12 at a particular time when, for example, it is desirable to run a simulation operation or the like, a sequence program for effecting the change must be executed. Much time is required to write such a sequence program and thus, the change must be anticipated well in advance to allow ample time to complete the sequence program. Hence, it is burdensome to have the change implemented at any given time.
In addition, to change the contents of the device memory 12 during a simulation operation or the like when data at the predetermined address of the device memory 12 matches a preset value, a sequence program to effect that change must be executed. Much time is required to write that sequence program and accordingly, it is difficult to have the program completed in time to change the contents of the device memory 12 immediately when the condition occurs.
Furthermore, to intentionally change the contents of the device memory 12 several times during simulation operation or the like, an operator must input new data from the input/output (peripheral equipment) 2 and transmit it to the programmable controller 1 every time an intentional change is made.
Hence, it is often difficult to match the timing of a change, to change the contents of the device memory 12 at a plurality of addresses simultaneously, or to reproduce an input signal of short duration (e.g., 0.1 seconds or less).